package cn.lanqiao.ui;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import cn.lanqiao.entiy.Student;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class StudentApplyImformationFrm extends JDialog {
	private JTextField sid;
	private JTextField sname;
	private JTextField ssex;
	private JTextField sproject;
	private JTextField suid;
	private JTextField stid;
	private JTextField sphone;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			StudentApplyImformationFrm dialog = new StudentApplyImformationFrm();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public StudentApplyImformationFrm() {
		setResizable(false);
		setBounds(100, 100, 449, 424);
		getContentPane().setLayout(null);
		
		JLabel lblNewLabel = new JLabel("编号");
		lblNewLabel.setBounds(85, 56, 48, 15);
		getContentPane().add(lblNewLabel);
		
		sid = new JTextField();
		sid.setBounds(143, 50, 197, 21);
		getContentPane().add(sid);
		sid.setColumns(10);
		
		JLabel label = new JLabel("姓名");
		label.setBounds(85, 89, 54, 15);
		getContentPane().add(label);
		
		sname = new JTextField();
		sname.setBounds(143, 81, 197, 21);
		getContentPane().add(sname);
		sname.setColumns(10);
		
		//居中
		this.setLocationRelativeTo(null);
		
		JLabel lblNewLabel_1 = new JLabel("性别");
		lblNewLabel_1.setBounds(85, 119, 54, 15);
		getContentPane().add(lblNewLabel_1);
		
		ssex = new JTextField();
		ssex.setBounds(143, 116, 197, 21);
		getContentPane().add(ssex);
		ssex.setColumns(10);
		
		JLabel lblNewLabel_2 = new JLabel("训练项目");
		lblNewLabel_2.setBounds(85, 151, 54, 15);
		getContentPane().add(lblNewLabel_2);
		
		JLabel label_1 = new JLabel("账号");
		label_1.setBounds(85, 187, 54, 15);
		getContentPane().add(label_1);
		
		JLabel label_2 = new JLabel("教练");
		label_2.setBounds(85, 227, 54, 15);
		getContentPane().add(label_2);
		
		sproject = new JTextField();
		sproject.setBounds(143, 148, 197, 21);
		getContentPane().add(sproject);
		sproject.setColumns(10);
		
		suid = new JTextField();
		suid.setBounds(143, 184, 197, 21);
		getContentPane().add(suid);
		suid.setColumns(10);
		
		stid = new JTextField();
		stid.setBounds(143, 224, 197, 21);
		getContentPane().add(stid);
		stid.setColumns(10);
		
		JButton button = new JButton("报名");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				 //1、获取文本框数据
				 String id=sid.getText();
			     String name=sname.getText();
			     String sex=ssex.getText();
			     String project=sproject.getText();
			     String uid=suid.getText();
			     String tid=stid.getText();
			     String phone=sphone.getText();
			
			      //判断对象是否为空
				
			       boolean idf= id.trim().equals("");
			       boolean namef= name.trim().equals("");
			       boolean sexf= sex.trim().equals("");
			       boolean projectf= project.trim().equals("");
			       boolean uidf= uid.trim().equals("");
			       boolean sidf= tid.trim().equals("");
			       boolean phonef= phone.trim().equals("");
			       
			       if(idf) {
			    	   JOptionPane.showMessageDialog(null,"信息不能为空，请填写信息");
			       }else if(namef){
			    	   JOptionPane.showMessageDialog(null,"信息不能为空，请填写信息");
			       }else if(sexf) {
			    	   JOptionPane.showMessageDialog(null,"信息不能为空，请填写信息");
			       }else if(projectf) {
			    	   JOptionPane.showMessageDialog(null,"信息不能为空，请填写信息");
			       }else if(uidf) {
			    	   JOptionPane.showMessageDialog(null,"信息不能为空，请填写信息");
			       }else if(sidf) {
			    	   JOptionPane.showMessageDialog(null,"信息不能为空，请填写信息");
			       }else if(phonef) {
			    	   JOptionPane.showMessageDialog(null,"信息不能为空，请填写信息");
			       }else {
			    	   JOptionPane.showMessageDialog(null,"教练选择成功，请联系教练进行训练");
			       }
			       
		
			    //封装成一个新的对象 
				     Student stu=new Student(id, name, sex, project, uid, tid, phone); 
			
 			  //  3、调用业务层
			    
	
			}

	
		});
		button.setBounds(283, 324, 93, 23);
		getContentPane().add(button);
		
		JButton btnNewButton = new JButton("取消");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		btnNewButton.setBounds(104, 324, 93, 23);
		getContentPane().add(btnNewButton);
		
		JLabel label_3 = new JLabel("电话");
		label_3.setBounds(85, 263, 54, 15);
		getContentPane().add(label_3);
		
		sphone = new JTextField();
		sphone.setBounds(143, 260, 197, 21);
		getContentPane().add(sphone);
		sphone.setColumns(10);
	}
}
